# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=hydrogen
pkgver=1.2.2
pkgrel=0
pkgdesc="Advanced drum machine for GNU/Linux"
url="http://www.hydrogen-music.org/"
arch="aarch64 armv7 ppc64le x86 x86_64" # armhf limited by qt5-qtxmlpatterns
license="GPL-2.0-or-later"
makedepends="
	alsa-lib-dev
	cmake
	flac-dev
	jack-dev
	ladspa-dev
	libarchive-dev
	libsndfile-dev
	portaudio-dev
	pulseaudio-dev
	qt5-qtbase-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qt5-qtxmlpatterns-dev
	samurai
	"
checkdepends="cppunit-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="hydrogen-$pkgver.tar.gz::https://github.com/hydrogen-music/hydrogen/archive/$pkgver.tar.gz
	nodevel.patch
	timeval.patch
	"
# tiny float differences
options="!check"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DWANT_CPPUNIT="$(want_check && echo ON || echo OFF)" \
		-DWANT_DEBUG=OFF \
		-DVERSION_SUFFIX=alpine \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	./build/src/tests/tests
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
bd6b102b14d30a8e2f4ea7e405199bb34f9b7691b57c3f9f3096c9e30c25c158e3bfd40bcfdd2d449bc153b7d3d9717df401f1e7a086e33dc953247870f1dee0  hydrogen-1.2.2.tar.gz
9135b7c4ec4818df3e28f9dfcc3d8a88f407ffd0a74ebc8ad0a29f91d514d667db93f03cc4f7cfaa65e4034c6f2270ec574ad32d79679e8b012a6f0c1bf13f7c  nodevel.patch
4bb2a64f4aca52fd961a564620bac6d822e92cfbaa2802a49ec7f15edb63aa77fecd29c2bb1ebbf90626f83d74ee9bf1b1e2868a133ed2a93ebd4e811868793e  timeval.patch
"
